Skip to content

Fix #2516: Support Packaging and Distribution #2524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 26, 2017

Conversation

liufengyun
Copy link
Contributor

@liufengyun liufengyun commented May 24, 2017

Fix #2516: This PR enable us to run brew install lampepfl/brew/dotty and then play with dotc/dotr in command line.

The packaging is based on sbt-pack:

  • sbt dist/pack: generate package under dist/target/pack/
  • sbt dist/pack-archive: generate .zip and .tar.gz files

@felixmulder
Copy link
Contributor

It seems to missing Dottydoc :)

Is this publishable to homebrew as is, and could you take care of that?

Otherwise LGTM

@liufengyun
Copy link
Contributor Author

The scripts are assumed to support mingw and cygwin, so windows users have a chance to play with Dotty 0.1 .

@liufengyun
Copy link
Contributor Author

@felixmulder I'm not sure if we need to publish the formula to Homebrew -- they have a lot of requirements on what can be accepted to brew-core, I think a shorter URL to the formula satisfy our need for now.

@olafurpg
Copy link
Contributor

For homebrew, I recommend creating a cask so users can install dotty via brew install lampepfl/dotty/dotty. I do that for scalafmt https://github.com/olafurpg/homebrew-scalafmt

Reminds me there should really be a scala cask under scala/homebrew-scala, only someone would need to maintain it 😢

dist/dotty.rb Outdated
class Dotty < Formula
desc "Experimental Scala Compiler"
homepage "http://dotty.epfl.ch/"
url "http://dotty.epfl.ch/dotty/dotty-0.1.1-bin-SNAPSHOT.tar.gz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the artifacts always be hosted on dotty.epfl.ch? Do you have scripts to automate the deployment?

I recommend against serving the files from an EPFL server. There have examples where servers hosting artifacts have been compromised http://www.techradar.com/news/popular-video-encoding-mac-app-handbrake-compromised-with-malware I think it would be best to serve these from for example Github releases or Maven Central. I have used https://github.com/aktau/github-release to automate this, but there are other ways.

Additionally, I suspect many will write installation scripts against this url scheme. For example nix, https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/scalafmt/default.nix I would recommend to try and keep this as stable as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the script I used to upload artifacts to github releases and update a homebrew formula https://github.com/scalameta/scalafmt/blob/ad8559939c7d32ca78dfedf3ebc4eebc2fda7257/bin/publish.sh#L52-L71 I don't use it anymore, I only publish to Maven Central now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the tip @olafurpg , I think we should automate the publishing to Github.

dist/dotty.rb Outdated
desc "Experimental Scala Compiler"
homepage "http://dotty.epfl.ch/"
url "http://dotty.epfl.ch/dotty/dotty-0.1.1-bin-SNAPSHOT.tar.gz"
sha256 "4e1bda148754543844d25290a87076e6bfb0b6b0275535f97c1871e0fc5c2c4c"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you upload the artifacts to Github releases, then the sha will be different than running sha locally. You would have to upload, download and then run sha on the dowloaded file.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I believe that it should be possible to provide a one-copy/paste install for all platforms in a similar way as ammonite (http://www.lihaoyi.com/Ammonite/#Ammonite-REPL) or Rust (https://www.rust-lang.org/en-US/install.html) However, I don't have much time at the moment to experiment with that. I think this is a great start!

dist/bin/dotd Outdated
default_java_opts="-Xmx768m -Xms768m"
bootcp=true

PROG_NAME=dotty.tools.dottydoc.Main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixmulder could you give me a tip on how the dottydoc script works? The main difference from dotc is just the main method?

I run dotd examples/hello.scala locally, but it seems we need more libraries: java.lang.NoClassDefFoundError: com/vladsch/flexmark/util/options/MutableDataSet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be fine - are you sure you've provided all dependencies? Dottydoc has some dependencies from Maven. See: https://github.com/lampepfl/dotty/blob/master/project/Build.scala#L304-L317

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixmulder We've a long list of dependencies if dottydoc is included. It doesn't look very nice. How about we do some assembly for dottydoc and do it in a separate PR?

  1. ST4-4.0.7.jar
  2. antlr-3.5.1.jar
  3. antlr-runtime-3.5.1.jar
  4. autolink-0.6.0.jar
  5. flexmark-0.11.1.jar
  6. flexmark-ext-anchorlink-0.11.1.jar
  7. flexmark-ext-autolink-0.11.1.jar
  8. flexmark-ext-emoji-0.11.1.jar
  9. flexmark-ext-gfm-strikethrough-0.11.1.jar
  10. flexmark-ext-gfm-tables-0.11.1.jar
  11. flexmark-ext-gfm-tasklist-0.11.1.jar
  12. flexmark-ext-ins-0.11.1.jar
  13. flexmark-ext-superscript-0.11.1.jar
  14. flexmark-ext-tables-0.11.1.jar
  15. flexmark-ext-wikilink-0.11.1.jar
  16. flexmark-ext-yaml-front-matter-0.11.1.jar
  17. flexmark-jira-converter-0.11.1.jar
  18. flexmark-util-0.11.1.jar
  19. jackson-annotations-2.2.3.jar
  20. jackson-core-2.8.6.jar
  21. jackson-databind-2.2.3.jar
  22. jackson-dataformat-yaml-2.8.6.jar
  23. jsoup-1.7.2.jar
  24. liqp-0.6.7.jar
  25. snakeyaml-1.17.jar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@liufengyun
Copy link
Contributor Author

@olafurpg I agree, we can improve the user experience for Linux/Windows as we go. Currently sbt-pack creates zip packages, it's more visible about what's released.

Copy link
Contributor

@DarkDimius DarkDimius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is good, but this implementation introduces a lot of duplication and possibility for bugs. The duplication is both between scripts in this PR and already existing scripts.
I propose we merge this scripts with current scripts in ./bin/ folder.
There's a lot of nececary functionality that is implemented there, such as crash handers and restoring of tty settings. The scripts has in ./bin are inherited from @miniboxing and they are used to work on Windows(cygwin).

@@ -0,0 +1,116 @@
#!/usr/bin/env bash

if [ -z "$PROG_HOME" ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of copy paste and re-implementation for the current bin/dotc script.
I propose we merge the two, otherwise it will be hard to maintain and we'll be using different scripts from the ones our users do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkDimius I agree there's a potential to merge the two. But I think we can delay the merge after the Copenhagen release -- as the bin/dotc and bin/dotr have something special to the development of the compiler, such as switch between bootstrap and unbootstrap versions. We can make the decision later.

dist/bin/dotd Outdated
@@ -0,0 +1,114 @@
#!/usr/bin/env bash

if [ -z "$PROG_HOME" ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to write separate scripts for multiple entry points. See how it's done in ./bin/dotc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkDimius I didn't get your point. This piece of code is a reliable way to get the package home in order to run source "$PROG_HOME/bin/common". bin/dotr and bin/dotc do exactly the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By multiple entry points I've meant that you had similar scripts that differ only in what class they invoke in the end.


# Try to autodetect real location of the script

if [ -z "$PROG_HOME" ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here.

@liufengyun
Copy link
Contributor Author

@DarkDimius The new scirpts are supposed to support both mingw and cygwin, the code is from sbt-pack, I assume it's more widely tested than the code from minibox.

Actually, I found bugs related to bin/dotc about how symlink is resolved. The code from sbt-pack is more reliable.

@DarkDimius
Copy link
Contributor

@liufengyun, ok, agreed.
But the point about duplication stands. We shouldn't have 3+ scripts to edit.

@liufengyun
Copy link
Contributor Author

@DarkDimius I just removed dotd, we'll address dottydoc in another PR.

Regarding dotr and dotc, I don't see any duplication. If you mean the initial code for locating PROG_HOME, bin/dotc and bin/dotr also do the same for DOTTY_ROOT -- that piece of code cannot be shared, as sharing requires locating PROG_HOME/DOTTY_ROOT first.

@liufengyun
Copy link
Contributor Author

liufengyun commented May 25, 2017

I've published a test release in lampepfl/homebrew-brew. The standard (pre-)releases will come from @felixmulder in lampepfl/dotty after this PR is merged.

Now programmers can do the following:

  • Mac OS: brew install lampepfl/brew/dotty, and play with dotc and dotr.
  • Linux/Windows: download the zip or tar.gz, decompress and run bin/dotc and bin/dotr.

It will be great that you can try the test release and give feedback, thanks a lot.

@DarkDimius
Copy link
Contributor

@liufengyun, just tried it on my mac. Works good so far.

@DarkDimius
Copy link
Contributor

#2531 and #2529 contains a bunch of fixes that we should get in before release.
Otherwise we'll have hard time figuring what version has a bug that user is experiencing.

@liufengyun
Copy link
Contributor Author

@DarkDimius I updated the test release with your fixes, it works well 👍

dist/bin/dotc Outdated
-nobootcp) unset bootcp && shift ;;
-colors) colors=true && shift ;;
-no-colors) unset colors && shift ;;
-jrebel) jrebel=true && shift ;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this option being used?

dist/bin/dotc Outdated
-colors) colors=true && shift ;;
-no-colors) unset colors && shift ;;
-jrebel) jrebel=true && shift ;;
-no-jrebel) unset jrebel && shift ;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixmulder I get them from the bin/dotc and bin/dotr. It seems it's fine to remove them. Doing it now.

dist/bin/dotc Outdated
-jrebel) jrebel=true && shift ;;
-no-jrebel) unset jrebel && shift ;;

-toolcp) require_arg classpath "$1" "$2" && toolcp="$2" && shift 2 ;;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently not supporting toolcp and it's not properly passed in bin/dotc. So I remove it for now, and add it back when we have toolcp support.

@felixmulder
Copy link
Contributor

Failure is due to bintray resolution?

@liufengyun
Copy link
Contributor Author

Yes, I restarted it -- the sbt-gpg plugin resolution failed.

@felixmulder
Copy link
Contributor

Could you add the artifactory resolver to the build from Fabien so that we get the caching?

@liufengyun
Copy link
Contributor Author

@felixmulder The CI passes -- I didn't get the latest URL of the resolver, we do it separately?

@olafurpg
Copy link
Contributor

FWIW, here's how I enabled the artifactory resolver only for CI scalacenter/scalafix@1c021f8#diff-fdc3abdfd754eeb24090dbd90aeec2ceR87

@olafurpg
Copy link
Contributor

But that does not enable the artifactory for resolving plugins, I would recommend instead to enable the artifactory globally in ~/.sbt/repositories in the docker image.

@felixmulder felixmulder merged commit 585ec67 into scala:master May 26, 2017
@felixmulder
Copy link
Contributor

@liufengyun - yes, it'd be good to get the patch into the docker image as well, but that's of lower priority right now.

@liufengyun liufengyun deleted the package branch May 26, 2017 08:59
@liufengyun
Copy link
Contributor Author

liufengyun commented May 26, 2017

Thanks @felixmulder ! If you decide to do a pre-release/release, you can follow the steps:

  • sbt dist/pack-archive locally
  • create a release on github with release message, upload the .zip and .tar.gz
  • update the URL and hash in the brew formula

Note: the hash is different when the artefact is uploaded. The travis CI will notice that if it's not set properly.

There's room to automate the process a little bit, but as we don't release daily, it's tolerable.

@felixmulder
Copy link
Contributor

Let's decide at the Monday meeting what to do. Thank for the info, looks great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants